package com.ruoyi.rsikManage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.rsikManage.domain.TAlgoTree;
import com.ruoyi.rsikManage.service.ITAlgoTreeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 算法树配置Controller
 *
 * @author sxygsj
 * @date 2024-06-27
 */
@RestController
@RequestMapping("/rsikManage/tree")
public class TAlgoTreeController extends BaseController
{
    @Autowired
    private ITAlgoTreeService tAlgoTreeService;

    /**
     * 查询算法树配置列表
     */
    //@PreAuthorize"@ss.hasPermi('rsikManage:tree:list')")
    @GetMapping("/list")
    public TableDataInfo list(TAlgoTree tAlgoTree)
    {
        startPage();
        List<TAlgoTree> list = tAlgoTreeService.selectTAlgoTreeList(tAlgoTree);
        return getDataTable(list);
    }

    /**
     * 导出算法树配置列表
     */
    //@PreAuthorize"@ss.hasPermi('rsikManage:tree:export')")
    @Log(title = "算法树配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TAlgoTree tAlgoTree)
    {
        List<TAlgoTree> list = tAlgoTreeService.selectTAlgoTreeList(tAlgoTree);
        ExcelUtil<TAlgoTree> util = new ExcelUtil<TAlgoTree>(TAlgoTree.class);
        util.exportExcel(response, list, "算法树配置数据");
    }

    /**
     * 获取算法树配置详细信息
     */
    //@PreAuthorize"@ss.hasPermi('rsikManage:tree:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tAlgoTreeService.selectTAlgoTreeById(id));
    }

    /**
     * 新增算法树配置
     */
    //@PreAuthorize"@ss.hasPermi('rsikManage:tree:add')")
    @Log(title = "算法树配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TAlgoTree tAlgoTree)
    {
        return toAjax(tAlgoTreeService.insertTAlgoTree(tAlgoTree));
    }

    /**
     * 修改算法树配置
     */
    //@PreAuthorize"@ss.hasPermi('rsikManage:tree:edit')")
    @Log(title = "算法树配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TAlgoTree tAlgoTree)
    {
        return toAjax(tAlgoTreeService.updateTAlgoTree(tAlgoTree));
    }

    /**
     * 删除算法树配置
     */
    //@PreAuthorize"@ss.hasPermi('rsikManage:tree:remove')")
    @Log(title = "算法树配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tAlgoTreeService.deleteTAlgoTreeByIds(ids));
    }
}
